/**
 * Selling Partner API for Product Type Definitions
 * The Selling Partner API for Product Type Definitions provides programmatic access to attribute and data requirements for product types in the Amazon catalog. Use this API to return the JSON Schema for a product type that you can then use with other Selling Partner APIs, such as the Selling Partner API for Listings Items, the Selling Partner API for Catalog Items, and the Selling Partner API for Feeds (for JSON-based listing feeds).  For more information, see the [Product Type Definitions API Use Case Guide](doc:product-type-api-use-case-guide).
 *
 * The version of the OpenAPI document: 2020-09-01
 *
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 *
 */

import { ApiClient } from '../ApiClient.js'
import { ProductTypeVersion } from './ProductTypeVersion.js'
import { PropertyGroup } from './PropertyGroup.js'
import { SchemaLink } from './SchemaLink.js'

/**
 * The ProductTypeDefinition model module.
 * @module producttypedefinitions_v2020_09_01/model/ProductTypeDefinition
 * @version 2020-09-01
 */
export class ProductTypeDefinition {
  /**
   * Constructs a new <code>ProductTypeDefinition</code>.
   * A product type definition represents the attributes and data requirements for a product type in the Amazon catalog. Product type definitions are used interchangeably between the Selling Partner API for Listings Items, Selling Partner API for Catalog Items, and JSON-based listings feeds in the Selling Partner API for Feeds.
   * @alias module:producttypedefinitions_v2020_09_01/model/ProductTypeDefinition
   * @class
   * @param schema {SchemaLink}
   * @param requirements {String} Name of the requirements set represented in this product type definition.
   * @param requirementsEnforced {String} Identifies if the required attributes for a requirements set are enforced by the product type definition schema. Non-enforced requirements enable structural validation of individual attributes without all of the required attributes being present (such as for partial updates).
   * @param propertyGroups {{String: PropertyGroup}} Mapping of property group names to property groups. Property groups represent logical groupings of schema properties that can be used for display or informational purposes.
   * @param locale {String} Locale of the display elements contained in the product type definition.
   * @param marketplaceIds {[String]} Amazon marketplace identifiers for which the product type definition is applicable.
   * @param productType {String} The name of the Amazon product type that this product type definition applies to.
   * @param displayName {String} Human-readable and localized description of the Amazon product type.
   * @param productTypeVersion {ProductTypeVersion}
   */
  constructor (schema, requirements, requirementsEnforced, propertyGroups, locale, marketplaceIds, productType, displayName, productTypeVersion) {
    this.schema = schema
    this.requirements = requirements
    this.requirementsEnforced = requirementsEnforced
    this.propertyGroups = propertyGroups
    this.locale = locale
    this.marketplaceIds = marketplaceIds
    this.productType = productType
    this.displayName = displayName
    this.productTypeVersion = productTypeVersion
  }

  /**
   * Constructs a <code>ProductTypeDefinition</code> from a plain JavaScript object, optionally creating a new instance.
   * Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
   * @param {Object} data The plain JavaScript object bearing properties of interest.
   * @param {ProductTypeDefinition} obj Optional instance to populate.
   * @return {ProductTypeDefinition} The populated <code>ProductTypeDefinition</code> instance.
   */
  static constructFromObject (data, obj) {
    if (data) {
      switch (typeof data) {
        case 'string':
          obj = String(data)
          break
        case 'number':
          obj = Number(data)
          break
        case 'boolean':
          obj = Boolean(data)
          break
      }
      obj = obj || new ProductTypeDefinition()
      if (data.hasOwnProperty('metaSchema')) { obj.metaSchema = SchemaLink.constructFromObject(data.metaSchema) }
      if (data.hasOwnProperty('schema')) { obj.schema = SchemaLink.constructFromObject(data.schema) }
      if (data.hasOwnProperty('requirements')) { obj.requirements = ApiClient.convertToType(data.requirements, 'String') }
      if (data.hasOwnProperty('requirementsEnforced')) { obj.requirementsEnforced = ApiClient.convertToType(data.requirementsEnforced, 'String') }
      if (data.hasOwnProperty('propertyGroups')) { obj.propertyGroups = ApiClient.convertToType(data.propertyGroups, { String: PropertyGroup }) }
      if (data.hasOwnProperty('locale')) { obj.locale = ApiClient.convertToType(data.locale, 'String') }
      if (data.hasOwnProperty('marketplaceIds')) { obj.marketplaceIds = ApiClient.convertToType(data.marketplaceIds, ['String']) }
      if (data.hasOwnProperty('productType')) { obj.productType = ApiClient.convertToType(data.productType, 'String') }
      if (data.hasOwnProperty('displayName')) { obj.displayName = ApiClient.convertToType(data.displayName, 'String') }
      if (data.hasOwnProperty('productTypeVersion')) { obj.productTypeVersion = ProductTypeVersion.constructFromObject(data.productTypeVersion) }
    }
    return obj
  }
}

/**
 * @member {SchemaLink} metaSchema
 * @type {SchemaLink}
 */
ProductTypeDefinition.prototype.metaSchema = undefined

/**
 * @member {SchemaLink} schema
 * @type {SchemaLink}
 */
ProductTypeDefinition.prototype.schema = undefined

/**
 * Allowed values for the <code>requirements</code> property.
 * @enum {String}
 * @readonly
 */
ProductTypeDefinition.RequirementsEnum = {

  /**
     * value: "LISTING"
     * @const
     */
  LISTING: 'LISTING',

  /**
     * value: "LISTING_PRODUCT_ONLY"
     * @const
     */
  LISTING_PRODUCT_ONLY: 'LISTING_PRODUCT_ONLY',

  /**
     * value: "LISTING_OFFER_ONLY"
     * @const
     */
  LISTING_OFFER_ONLY: 'LISTING_OFFER_ONLY'
}

/**
 * Name of the requirements set represented in this product type definition.
 * @member {String} requirements
 * @type {String}
 */
ProductTypeDefinition.prototype.requirements = undefined

/**
 * Allowed values for the <code>requirementsEnforced</code> property.
 * @enum {String}
 * @readonly
 */
ProductTypeDefinition.RequirementsEnforcedEnum = {

  /**
     * value: "ENFORCED"
     * @const
     */
  ENFORCED: 'ENFORCED',

  /**
     * value: "NOT_ENFORCED"
     * @const
     */
  NOT_ENFORCED: 'NOT_ENFORCED'
}

/**
 * Identifies if the required attributes for a requirements set are enforced by the product type definition schema. Non-enforced requirements enable structural validation of individual attributes without all of the required attributes being present (such as for partial updates).
 * @member {String} requirementsEnforced
 * @type {String}
 */
ProductTypeDefinition.prototype.requirementsEnforced = undefined

/**
 * Mapping of property group names to property groups. Property groups represent logical groupings of schema properties that can be used for display or informational purposes.
 * @member {{String: PropertyGroup}} propertyGroups
 * @type {{String: PropertyGroup}}
 */
ProductTypeDefinition.prototype.propertyGroups = undefined

/**
 * Locale of the display elements contained in the product type definition.
 * @member {String} locale
 * @type {String}
 */
ProductTypeDefinition.prototype.locale = undefined

/**
 * Amazon marketplace identifiers for which the product type definition is applicable.
 * @member {[String]} marketplaceIds
 * @type {[String]}
 */
ProductTypeDefinition.prototype.marketplaceIds = undefined

/**
 * The name of the Amazon product type that this product type definition applies to.
 * @member {String} productType
 * @type {String}
 */
ProductTypeDefinition.prototype.productType = undefined

/**
 * Human-readable and localized description of the Amazon product type.
 * @member {String} displayName
 * @type {String}
 */
ProductTypeDefinition.prototype.displayName = undefined

/**
 * @member {ProductTypeVersion} productTypeVersion
 * @type {ProductTypeVersion}
 */
ProductTypeDefinition.prototype.productTypeVersion = undefined
